package com.dachuang.canjiren.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dachuang.canjiren.entity.Register;
import com.dachuang.canjiren.entity.User;
import com.dachuang.canjiren.mapper.RegisterMapper;
import com.dachuang.canjiren.service.MailService;
import com.dachuang.canjiren.service.RegisterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;


@Service
public class RegisterServiceImpl extends ServiceImpl<RegisterMapper, Register> implements RegisterService {

    @Autowired
    private MailService mailService;



    @Override
    public User FindAllInfoByUserEmail(String email) {
        return baseMapper.FindAllInfoByUserEmail(email);
    }

    @Override
    public void add(Register register) {
            //获取激活码
            String code = register.getActiveCode();
            System.out.println("激活码:"+code);
            //主题
            String subject = "来自残疾人公益网站的激活邮件";
            //上面的激活码发送到用户注册邮箱
            String context = "<a href=\"http://localhost:8080/pub/checkCode?code="+code+"\">激活请点击:"+code+"</a>";
            //发送激活邮件
            mailService.sendMimeMail (register.getEmail(),subject,context);


    }
}
